﻿package com.designoutput.ui.controls
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import com.designoutput.manager.ResourceManager;

    public class MenuTitle extends Sprite
    {
        internal var bg:Sprite;
        internal var title:TextField;

        public function MenuTitle(text:String, name:String)
        {
            this.name = name;
            this.title = new TextField();
            this.title.defaultTextFormat = new TextFormat("Arial,Helvetica,San-serif", 12, 16777215, false, false, false, null, null, "left");
            this.title.multiline = false;
            this.title.selectable = false;
            this.title.autoSize = TextFieldAutoSize.LEFT;
            this.title.height = 16;
            this.title.text = ResourceManager.getValue(text);
            this.title.x = 8;
            this.title.y = 1;
            this.bg = new Sprite();
            this.bg.graphics.beginFill(0);
            this.bg.graphics.drawRect(0, 0, Math.round(this.title.width) + 16, 19);
            this.bg.graphics.endFill();
            this.bg.alpha = 0;
            addChild(this.bg);
            addChild(this.title);
            this.addEventListener(MouseEvent.ROLL_OVER, this.MouseOver);
            this.addEventListener(MouseEvent.ROLL_OUT, this.MouseOut);
        }

        private function MouseOut(event:MouseEvent) : void
        {
            this.bg.alpha = 0;
        }

        private function MouseOver(event:MouseEvent) : void
        {
            this.bg.alpha = 0.5;
        }

    }
}
